<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="./../layui/css/layui.css" media="all">
    <script src="./../layui/layui.js"></script>
    <script src="./../js/jquery-1.8.3.min.js"></script>
    <script src="./../js/env.js"></script>
    <script>
        if(layui.sessionData('user').userInfo===undefined){
            window.location.href = "../html/login.html"
        }
    </script>
    <title>IC卡用户</title>
    <style>
        .demoTable {
            margin: 10px 0 2px 10px;
        }
    </style>
</head>

<body>
<fieldset class="layui-elem-field layui-field-title"  >
    <legend>IC卡管理</legend>
</fieldset>
<!--<div class="demoTable"  >-->
    <!--<button class="layui-btn layui-btn-radius"   data-method="offset" type="button"-->
            <!--style="background-color: #0092EF;" onclick="javascript:window.location.href='./add/agent_add.html'">添加代理商-->
    <!--</button>-->
<!--</div>-->
<form class="layui-form" action="">
    <div class="demoTable"  >
        <div class="layui-form-item">
            <div class="layui-inline" >
                <label class="layui-form-label">卡号</label>
                <div class="layui-input-inline">
                    <input type="text" id="cardNum"  name="cardNum" lay-verify="required" autocomplete="off"
                           class="layui-input">
                </div>
            </div>



            <button class="layui-btn" onclick="sech()"  data-method="offset" type="button" >搜索 </button>

        </div>
    </div>

</form>


<script type="text/html" id="barDemo">
    <button  lay-event="edit" class="layui-btn layui-btn-sm layui-btn-normal" onclick="recharge()" style="background: green">操作</button>&nbsp;

    <!--等于0的时候就是启用  按钮显示禁用-->
    <!--{{#  if(d.isDisable == 0 ){ }}-->
    <!--<button onclick="jinyong('{{d.id}}')" type="button" class="layui-btn layui-btn-sm layui-btn-normal" style="background:dodgerblue">禁用</button>&nbsp;-->
    <!--{{#  } else { }}-->
    <!--<button onclick="qiyong('{{d.id}}')" type="button" class="layui-btn layui-btn-sm layui-btn-normal" style="background:dodgerblue">启用</button>&nbsp;-->

    <!--{{#  } }}-->
</script>

    <table id="demo" lay-filter="test"></table>
</body>

</html>
<script>
    layui.use(['form', 'layedit', 'laydate','table'], function(){
        var form = layui.form
            ,$ = layui.jquery
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate
            ,table = layui.table;

        var whereData={};

        whereData.cardNum = $("#cardNum").val();

        //第一个实例
        table.render({
            elem: '#demo'
            , height: 312
            ,where:whereData
            , url: abc() + '/agent/stockUser/selectIcAllStockUser?agentUserId='+1//数据接口
            , page: true //开启分页
            , cols: [[ //表头
                { field: 'id', title: 'id', sort: true, fixed: 'left', align: 'center' }
                , { field: 'userUid', title: 'Uid', align: 'center' }
                , { field: 'createTime', title: '创建时间', align: 'center' }
                , { field: 'chargeTotalMoney', title: '充电总金额', align: 'center' }
                , { field: 'chargeNum', title: '充电总度数', align: 'center' }
                , { field: 'chargeCount', title: '充电总次数', align: 'center' }
                , { field: 'userType', title: '类型', align: 'center' }
                , { field: 'usableFund', title: '钱包余额', align: 'center' }
                , { field: 'cardNum', title: '卡号', align: 'center' }
                , { field: 'agentAccount', title: '代理账号', align: 'center' }
                , { field: 'agentUsername', title: '代理名字', align: 'center' }
                , { field: 'agentUserId', title: '代理id', align: 'center' }
                , { field: 'operation', title: '操作',width:200, align: 'center',toolbar: '#barDemo' }

            ]]
            ,id:'testReload'
            , request: {
                pageName: 'page' //页码的参数名称，默认：page
                , limitName: 'pageSize' //每页数据量的参数名，默认：limit
            }
            , parseData: function (res) { //res 即为原始返回的数据
                if (res.code !== 0) {
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg //解析提示文本
                    };
                } else {
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.data.total, //解析数据长度
                        "data": res.data.list //解析数据列表
                    };
                }

            }
        });
    });

</script>
<script>
    //搜索
    function sech(){

        var whereData={};

        whereData.cardNum = $("#cardNum").val();
        //表刷新方法
        var table = layui.table;
        table.reload('testReload', {
            url:  abc() + '/agent/stockUser/selectIcAllStockUser?agentUserId='+1
            , where: whereData
        });

    }

    function recharge() {
        layer.open({
            type: 2,
            title: '充值',
            shadeClose: false,
            maxmin: true,
            area: ['470px', '470px'],
            content: '././recharge/recharge.html',
            success: function (layero, index) {
                var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();

            }
        });
    }


    
</script>